#pragma once 

#include <string>

#define Die(code) \
    do{\
        exit(code);\
    }while(0)

#define CONV(v) (struct sockaddr*)(v)

enum
{
    USAGE_ERROR = 1,
    SOCKET_ERROR,
    BIND_ERROR
};

//分割单词
bool Divide(const std::string &word, const std::string &sep, std::string *key, std::string *value)
{
    auto pos = word.find(sep);
    if (pos == std::string::npos) return false;
    *key = word.substr(0, pos);
    *value = word.substr(pos + sep.size());
    if (key->empty() || value->empty()) return false;
    return true;
}